home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / system / mail / transpor / ifmail23.z / ifmail23 / ifmail / ifcico / zmodem.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-07  |  7.0 KB  |  188 lines

  1. #ifndef ZMODEM_H
  2. #define ZMODEM_H
  3.  
  4. #ifndef TRUE
  5. #define TRUE 1
  6. #endif
  7.  
  8. #ifndef OK
  9. #define OK 0
  10. #endif
  11.  
  12. #ifndef FALSE
  13. #define FALSE 0
  14. #endif
  15.  
  16. #define RETRYMAX 10
  17. #define MAXBLOCK 8192
  18.  
  19. /*
  20.  *   Z M O D E M . H     Manifest constants for ZMODEM
  21.  *    application to application file transfer protocol
  22.  *    04-17-89  Chuck Forsberg Omen Technology Inc
  23.  */
  24. #define ZPAD '*'    /* 052 Padding character begins frames */
  25. #define ZDLE 030    /* Ctrl-X Zmodem escape - `ala BISYNC DLE */
  26. #define ZDLEE (ZDLE^0100)    /* Escaped ZDLE as transmitted */
  27. #define ZBIN 'A'    /* Binary frame indicator (CRC-16) */
  28. #define ZHEX 'B'    /* HEX frame indicator */
  29. #define ZBIN32 'C'    /* Binary frame with 32 bit FCS */
  30. #define ZBINR32 'D'    /* RLE packed Binary frame with 32 bit FCS */
  31. #define ZVBIN 'a'    /* Binary frame indicator (CRC-16) */
  32. #define ZVHEX 'b'    /* HEX frame indicator */
  33. #define ZVBIN32 'c'    /* Binary frame with 32 bit FCS */
  34. #define ZVBINR32 'd'    /* RLE packed Binary frame with 32 bit FCS */
  35. #define ZRESC    0176    /* RLE flag/escape character */
  36. #define ZMAXHLEN 16    /* Max header information length  NEVER CHANGE */
  37. #define ZMAXSPLEN 1024    /* Max subpacket length  NEVER CHANGE */
  38.  
  39. /* Frame types (see array "frametypes" in zm.c) */
  40. #define ZRQINIT    0    /* Request receive init */
  41. #define ZRINIT    1    /* Receive init */
  42. #define ZSINIT 2    /* Send init sequence (optional) */
  43. #define ZACK 3        /* ACK to above */
  44. #define ZFILE 4        /* File name from sender */
  45. #define ZSKIP 5        /* To sender: skip this file */
  46. #define ZNAK 6        /* Last packet was garbled */
  47. #define ZABORT 7    /* Abort batch transfers */
  48. #define ZFIN 8        /* Finish session */
  49. #define ZRPOS 9        /* Resume data trans at this position */
  50. #define ZDATA 10    /* Data packet(s) follow */
  51. #define ZEOF 11        /* End of file */
  52. #define ZFERR 12    /* Fatal Read or Write error Detected */
  53. #define ZCRC 13        /* Request for file CRC and response */
  54. #define ZCHALLENGE 14    /* Receiver's Challenge */
  55. #define ZCOMPL 15    /* Request is complete */
  56. #define ZCAN 16        /* Other end canned session with CAN*5 */
  57. #define ZFREECNT 17    /* Request for free bytes on filesystem */
  58. #define ZCOMMAND 18    /* Command from sending program */
  59. #define ZSTDERR 19    /* Output to standard error, data follows */
  60.  
  61. /* ZDLE sequences */
  62. #define ZCRCE 'h'    /* CRC next, frame ends, header packet follows */
  63. #define ZCRCG 'i'    /* CRC next, frame continues nonstop */
  64. #define ZCRCQ 'j'    /* CRC next, frame continues, ZACK expected */
  65. #define ZCRCW 'k'    /* CRC next, ZACK expected, end of frame */
  66. #define ZRUB0 'l'    /* Translate to rubout 0177 */
  67. #define ZRUB1 'm'    /* Translate to rubout 0377 */
  68.  
  69. /* zdlread return values (internal) */
  70. /* -1 is general error, -2 is timeout */
  71. #define GOTOR 0400
  72. #define GOTCRCE (ZCRCE|GOTOR)    /* ZDLE-ZCRCE received */
  73. #define GOTCRCG (ZCRCG|GOTOR)    /* ZDLE-ZCRCG received */
  74. #define GOTCRCQ (ZCRCQ|GOTOR)    /* ZDLE-ZCRCQ received */
  75. #define GOTCRCW (ZCRCW|GOTOR)    /* ZDLE-ZCRCW received */
  76. #define GOTCAN    (GOTOR|030)    /* CAN*5 seen */
  77.  
  78. /* Byte positions within header array */
  79. #define ZF0    3    /* First flags byte */
  80. #define ZF1    2
  81. #define ZF2    1
  82. #define ZF3    0
  83. #define ZP0    0    /* Low order 8 bits of position */
  84. #define ZP1    1
  85. #define ZP2    2
  86. #define ZP3    3    /* High order 8 bits of file position */
  87.  
  88. /* Bit Masks for ZRINIT flags byte ZF0 */
  89. #define CANFDX    01    /* Rx can send and receive true FDX */
  90. #define CANOVIO    02    /* Rx can receive data during disk I/O */
  91. #define CANBRK    04    /* Rx can send a break signal */
  92. #define CANRLE    010    /* Receiver can decode RLE */
  93. #define CANLZW    020    /* Receiver can uncompress */
  94. #define CANFC32    040    /* Receiver can use 32 bit Frame Check */
  95. #define ESCCTL 0100    /* Receiver expects ctl chars to be escaped */
  96. #define ESC8   0200    /* Receiver expects 8th bit to be escaped */
  97.  
  98. /* Bit Masks for ZRINIT flags byte ZF1 */
  99. #define CANVHDR    01    /* Variable headers OK */
  100.  
  101. /* Parameters for ZSINIT frame */
  102. #define ZATTNLEN 32    /* Max length of attention string */
  103. #define ALTCOFF ZF1    /* Offset to alternate canit string, 0 if not used */
  104. /* Bit Masks for ZSINIT flags byte ZF0 */
  105. #define TESCCTL 0100    /* Transmitter expects ctl chars to be escaped */
  106. #define TESC8   0200    /* Transmitter expects 8th bit to be escaped */
  107.  
  108. /* Parameters for ZFILE frame */
  109. /* Conversion options one of these in ZF0 */
  110. #define ZCBIN    1    /* Binary transfer - inhibit conversion */
  111. #define ZCNL    2    /* Convert NL to local end of line convention */
  112. #define ZCRESUM    3    /* Resume interrupted file transfer */
  113. /* Management include options, one of these ored in ZF1 */
  114. #define ZMSKNOLOC    0200    /* Skip file if not present at rx */
  115. /* Management options, one of these ored in ZF1 */
  116. #define ZMMASK    037    /* Mask for the choices below */
  117. #define ZMNEWL    1    /* Transfer if source newer or longer */
  118. #define ZMCRC    2    /* Transfer if different file CRC or length */
  119. #define ZMAPND    3    /* Append contents to existing file (if any) */
  120. #define ZMCLOB    4    /* Replace existing file */
  121. #define ZMNEW    5    /* Transfer if source newer */
  122.     /* Number 5 is alive ... */
  123. #define ZMDIFF    6    /* Transfer if dates or lengths different */
  124. #define ZMPROT    7    /* Protect destination file */
  125. /* Transport options, one of these in ZF2 */
  126. #define ZTLZW    1    /* Lempel-Ziv compression */
  127. #define ZTRLE    3    /* Run Length encoding */
  128. /* Extended options for ZF3, bit encoded */
  129. #define ZXSPARS    64    /* Encoding for sparse file operations */
  130. #define ZCANVHDR    01    /* Variable headers OK */
  131. /* Receiver window size override */
  132. #define ZRWOVR 4    /* byte position for receive window override/256 */
  133.  
  134. /* Parameters for ZCOMMAND frame ZF0 (otherwise 0) */
  135. #define ZCACK1    1    /* Acknowledge, then do command */
  136.  
  137. long rclhdr();
  138.  
  139. /* Globals used by ZMODEM functions */
  140. extern int Rxframeind;    /* ZBIN ZBIN32, or ZHEX type of frame */
  141. extern int Rxtype;        /* Type of header received */
  142. extern int Rxcount;        /* Count of data bytes received */
  143. extern int long Rxpos;    /* Received file position */
  144. extern int long Txpos;    /* Transmitted file position */
  145. extern int Txfcs32;        /* TURE means send binary frames with 32 bit FCS */
  146. extern int Crc32t;        /* Display flag indicating 32 bit CRC being sent */
  147. extern int Crc32r;        /* Display flag indicating 32 bit CRC being received */
  148. extern int Crc32;        /* Display flag indicating 32 bit CRC being received */
  149. extern int Znulls;        /* Number of nulls to send at beginning of ZDATA hdr */
  150. extern char Rxhdr[];
  151. extern char Txhdr[];
  152. extern char Attn[ZATTNLEN+1];    /* Attention string rx sends to tx on err */
  153. extern char *Altcan;    /* Alternate canit string */
  154. extern char *Zendnames[];
  155. extern char *txbuf;
  156. extern char *rxbuf;
  157.  
  158. /* End of ZMODEM.H */
  159.  
  160. extern int Zrwindow;
  161. extern int Effbaud;
  162. extern int Zmodem;
  163. extern int Zctlesc;
  164. extern int Filesleft;
  165. extern long Totalleft;
  166.  
  167. extern char *frametypes[];
  168. #define FTOFFSET 16
  169.  
  170. extern void zsbhdr(int,int,char*);
  171. extern void zshhdr(int,int,char*);
  172. extern int  zgethdr(char*,int);
  173. extern void zsdata(char*,int,int);
  174. extern int  zrdata(char*,int);
  175. extern void stohdr(long);
  176.  
  177. extern void zsendline(int);
  178. extern void zsdar32(char*,int,int);
  179. extern int  zrdatr32(char*,int);
  180. extern int  zdlread(void);
  181.  
  182. extern unsigned short crc16tab[];
  183. extern unsigned long  crc32tab[];
  184. #define updcrc16(cp,crc) (crc16tab[(((int)crc >> 8) & 0xff)] ^ (crc << 8) ^ cp)
  185. #define updcrc32(cp,crc) (crc32tab[((int)crc ^ cp) & 0xff] ^ ((crc >> 8) & 0x00ffffff))
  186.  
  187. #endif
  188.